package prac8;
/**
 * Generic list interface 
 * 
 * @author          Maria Garcia de la Banda
 * @param           <T> type of element to be stored in this list
 * @since           July 2011
 * @knownBugs       none
 */

interface List<T> extends MyIterable<T> {
    /**
     * Interface for the list iterator.
     * 
     * @author    Maria Garcia de la Banda
     */
    
    /*
     * Invariants:
     */
    /**
     * Determines whether the list is empty.
     * 
     * @return      true if the list is empty, false otherwise
     * @post        the list is unchanged
     * @complexity  best and worst case: O(1) 
     */
    boolean isEmpty();

    /**
     * Determines whether the list is full.
     * Method introduced for consistency with the list implemented with arrays.
     * 
     * @return      false
     * @post        returns false
     * @post        the list is unchanged
     */
    boolean isFull();

    /**
     * Empties the list.
     * 
     * @post        the list is empty
     */
    void clear();

    /**
     * Creates a new iterator for the list.
     * 
     * @return      new abstract list iterator
     * @see         Iterator#Iterator()
     */
    Iterator<T> iterator();

    /**
     * Attempts to find an item in the list.
     * 
     * @param       item to search for in this list 
     * @return      returns false if the item does not appear in the list,
     *              and true if it does.
     */
    boolean find(T thisItem);

    /**
     * Adds a new item to this list.
     * 
     * @param       item to add to this list
     * @post        the item will appear in the list (not known where)
     */
    abstract void add(T newItem);

    /**
     * Returns the first element in the list, and eliminates from it.
     * 
     * @return      the first element in the list
     * @pre         the list is not empty
     * @post        the list contains the same elements as before except for
     *              the first one.
     */
    T deleteFirst();

    /**
     * Returns the last element in the list, and eliminates from it.
     * 
     * @return      the last element in the list
     * @pre         the list is not empty
     * @post        the list contains the same elements as before except for
     *              the last one.
     */
    T deleteLast();

    /**
     * Removes the input item from the list (if exists).
     * 
     * @param       the item to be deleted
     * @return      returns true if the input item appears in the list,
     *              and false otherwise.
     * @post        the list contains the same elements as before except for
     *              the element that contained item
     */
    boolean deleteItem(T thisItem);
    /**
     * @return      length of this list
     */
    int size();
    
}       

